<template>
  <div>
    <div>
      <BasicForm ref="formRef" @gotDbInfo="handleDbInfo" @uploadSuccess="handleUploadSuccess"></BasicForm>

      <div class="h-full">
        <SqlRecord @uploadScript="handleUploadScript" ref="table" v-bind:dbInfo="dbInfo"></SqlRecord>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import BasicForm from './BasicForm.vue';
import SqlRecord from './record-table/index.vue';

let dbInfo = ref('');
const table = ref(null);
const formRef = ref(null);
const handleDbInfo = function (payload) {
  dbInfo.value = payload;
  table.value.reload();
};

const handleUploadSuccess = function (data) {
  if (data) {
    table.value.reload();
  }
};
const handleUploadScript = (params: any) => {
  formRef.value.openDrawer(params);
};
</script>
